package com.example.webflux.reactive;

import java.util.Random;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntUnaryOperator;

/**
 * @author lyl
 * @create 2021-07-18 21:38
 */
public class LambdaDemo {
    public static void main(String[] args) {
        Function<Integer, String> func = a -> String.valueOf(a);
        String s = func.apply(99);
        System.out.println(s);

        Function<Integer, String> func1 = String::valueOf;
        String s1 = func1.apply(99);
        System.out.println(s1);

        Consumer<String> consumer = System.out::println;
        consumer.accept("hhh");

        BiFunction<Integer, Integer, Double> func2 = (a, b) -> Math.pow(a, b);
        Double resulit = func2.apply(3, 4);
        System.out.println(resulit);

        BiFunction<Integer, Integer, Double> function1 = Math::pow;
        Double apply = function1.apply(3, 4);
        System.out.println(apply);

        Random random = new Random();
        IntUnaryOperator func4 = i -> random.nextInt(i);
        int applyAsInt = func4.applyAsInt(10);
        System.out.println(applyAsInt);

        IntUnaryOperator func5 = random::nextInt;
        System.out.println(func5.applyAsInt(19));


    }
}
